<template>
  <el-dialog :visible.sync="visible" v-dialogDrag :title="title" :close-on-click-modal="false" class="tl-dialog" width="1200px" @open="open" @close="close">
    <el-form class="tl-form" ref="form" :model="model" :rules="rules" label-width="150px" :disabled="disableEditSubmit">
      <el-row>
        <el-col :span="12">
          <el-form-item label="风险编号" prop="code">
            <el-input v-model="model.code" readonly class="is-disabled" style="width:95%"></el-input>
            <tl-help ref="help">新增时自动生成 </tl-help>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="风险级别" prop="risklevel" :rules="rules.validateRequireSelect">
            <el-select v-model="model.risklevel" filterable clearable>
              <el-option v-for="item in codeModel.risklevelList" :key="item.code" :label="item.name" :value="item.code" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="风险状态" prop="status" :rules="rules.validateRequireSelect">
            <el-select v-model="model.status" filterable clearable>
              <el-option v-for="item in codeModel.statusList" :key="item.code" :label="item.name" :value="item.code" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="风险性质" prop="attribute" :rules="rules.validateRequireSelect">
            <el-select v-model="model.attribute" filterable clearable>
              <el-option v-for="item in codeModel.attributeList" :key="item.code" :label="item.name" :value="item.code" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="发生概率" prop="probability" :rules="rules.validateRequireSelect">
            <el-select v-model="model.probability" filterable clearable>
              <el-option v-for="item in codeModel.probabilityList" :key="item.code" :label="item.name" :value="item.code" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="责任人" prop="riskownercode" :rules="rules.validateRequireSelect">
            <tl-ref-user v-model="model.riskownercode" :initDisplayData.sync="model.riskownername" dataType="code" :singleSelect="true"></tl-ref-user>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="风险描述" prop="detail" :rules="rules.validateRequire">
            <el-input v-model="model.detail" type="textarea" :rows="3"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="应对措施" prop="solution">
            <el-input v-model="model.solution" type="textarea" :rows="3"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="备注" prop="description">
            <el-input v-model="model.description" type="textarea" :rows="3"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button :type="disableEditSubmit === false ? 'text' : 'primary'" @click="doCancelEdit">取消</el-button>
      <el-button type="primary" @click="doSubmitEdit" :loading="saveLoading" v-if="disableEditSubmit === false">确认</el-button>
    </div>
  </el-dialog>
</template>

<script>
/** mixins */
import { mixin_edit } from '@tapui/mixins/mixin_edit'
/** 子组件 */
/** 工具类 */
import { putAction, getAction, postAction, deleteAction } from '@tapui/utils/http'
/** VUE配置 */
export default {
  mixins: [mixin_edit],
  components: {},
  data() {
    return {
      moduleTitle: '项目风险',
      urlPrefix: '/base/cbbPmRisk/',
      url: {
        // 额外的url
      },
      addRules: {
        validateRequireSelect: [
          // 必选
          { required: 'true', message: '请选择内容', trigger: 'change' }
        ]
      }
    }
  },
  props: {
    /** 项目号 */
    projectcode: {
      type: String
    }
  },
  methods: {
    loaded() {
      // 页面加载完毕执行
      if (this.isAdd) {
        this.$set(this.model, 'status', "0")
        this.$set(this.model, 'attribute', "0")
        this.$set(this.model, 'projectuucode', this.projectcode)
      }
    }
  }
}
</script>
